//
//  main.cpp
//  ++运算符重载
//
//  Created by linjinzhu on 2017/7/12.
//  Copyright © 2017年 baidu. All rights reserved.
//

#include <iostream>

using namespace std;

class Time {
private:
    int minute;
    int hour;

public:
    Time() {minute = hour = 0;}
    Time(int h, int m) {
        hour = h;
        minute = m;
    }

    void display() {
        cout << hour << ":" << minute << endl;
    }

    Time operator++() {
        // 对象加1
        ++minute;
        if (minute >= 60) {
            ++hour;
            minute -= 60;
        }


        return Time(hour, minute);
    }

    Time operator++(int) {
        Time T(hour, minute);

        ++minute;
        if (minute >= 60) {
            ++hour;
            minute -= 60;
        }

        return T;
    }
};

int main(int argc, const char * argv[]) {

    Time t1(0, 0);
    Time t2(2, 50);

    t1.display();
    t2.display();

    for (int i=0; i<3600; i++) {
        ++t1;
        t1.display();
    }

    return 0;
}
